package scala40rules;

import java.awt.Image;
import java.awt.Toolkit;
import java.io.Serializable;
import javax.swing.ImageIcon;


public class Card implements Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;


	private int ordinalValue;
	private String symbol;
	private String suit;
	private boolean redBack;
    private String image;
    private ImageIcon icon;
    private String iconPath;




	
	public Card(){
		this.iconPath = "src/small_cards/carta_vuota.png";
		//this.icon=new ImageIcon("src/small_cards/carta_vuota.png");
//		this.image="";
	}

	public Card(int ordinalValue, String symbol, String suit, boolean redBack, String image){
		this.ordinalValue= ordinalValue;
		this.symbol=symbol;
		this.suit=suit;
		this.redBack=redBack;
                this.image=image;
	}

        public Card(int ordinalValue, String symbol, String suit, boolean redBack){
		this.ordinalValue= ordinalValue;
		this.symbol=symbol;
		this.suit=suit;
		this.redBack=redBack;
	}

    public Card(int ordinalValue, String symbol, String suit, boolean redBack, String image, String pathIcon) {
                this.ordinalValue= ordinalValue;
		this.symbol=symbol;
		this.suit=suit;
		this.redBack=redBack;
                this.image=image;
                this.iconPath=pathIcon;
                //icon=new ImageIcon(pathIcon);
    }


	public int getOrdinalValue() {
		return ordinalValue;
	}

	public void setOrdinalValue(int ordinalValue) {
		this.ordinalValue = ordinalValue;
	}

	public String getSymbol() {
		return symbol;
	}

	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	public String getSuit() {
		return suit;
	}

	public void setSuit(String suit) {
		this.suit = suit;
	}

	public boolean getRedBack() {
		return redBack;
	}


	public void setRedBack(boolean red) {
		this.redBack = red;
	}

	public boolean isJoker(){
		return (this.getOrdinalValue() == 14);
	}

	public boolean isJokerWithoutSuit(){
		return ((this.getOrdinalValue() == 14) && (this.getSuit().equalsIgnoreCase(" ")));
	}

	public boolean equalCard(Card c){
		if( !(this.redBack == c.getRedBack())
				|| (this.isJoker() && c.isJoker())
				|| ( this.ordinalValue != c.getOrdinalValue())
				|| ( this.suit != c.getSuit())
				|| ( this.symbol != c.getSymbol())  ){
			return false;
		}
		else{
			return true;
		}

	}

	public boolean isEmpty(){
		if(  ( this.suit != null)
				&& ( this.symbol != null)  ){
			return false;
		}
		else{
			return true;
		}
	}

        public Image getImage() {
            return Toolkit.getDefaultToolkit().getImage(image);
        }

        public void setImage(String image) {
            this.image = image;
        }

        public ImageIcon getIcon() {
        	ImageIcon icona = new ImageIcon(this.iconPath);
            return icona;
            // return this.icon;
        }

        public void setIcon(ImageIcon icon) {
            this.icon = icon;
        }


}
